import { View } from "../../../../mvc/core/View";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { GUIComponent } from "../../../../../com/mui/controls/GUIComponent";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { ResFileConst } from "../../../resource/ResFileConst";
import { FrameTimer } from "../../../../../com/gengine/core/frame/FrameTimer";
import { TimerType } from "../../../../../com/gengine/core/frame/TimerType";
import { LayerManager } from "../../../manager/LayerManager";
import { Global } from "../../../../../com/gengine/global/Global";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { EffectManager } from "../../../manager/EffectManager";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
type int = number;
//class RoashProgressBar
    
    export  class RoashProgressBar extends View
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var toolTipData: string;
            var callBack: Function;

            var loc1;
            toolTipData = null;
            callBack = (): void
            {
                var loc5=null;
                var loc1=GlobalClass.getScaleBitmap("RoastFishBg", new Object /* flash.geom.Rectangle */(100, 0, 1, 1));
                loc1.width = 628;
                addChild(loc1);
                var loc2=new GUIComponent();
                loc2.x = 17;
                loc2.y = 55;
                var loc3=GlobalClass.getScaleBitmap("RoashProgcessBar1", new Object /* flash.geom.Rectangle */(20, 0, 1, 1));
                var loc4=GlobalClass.getScaleBitmap("RoashProgcessBar2", new Object /* flash.geom.Rectangle */(15, 0, 1, 1));
                loc5 = GlobalClass.getScaleBitmap("RoashProgcessBar3", new Object /* flash.geom.Rectangle */(15, 0, 1, 1));
                var loc6=GlobalClass.getScaleBitmap("RoashProgcessBar4", new Object /* flash.geom.Rectangle */(10, 0, 1, 1));
                var loc7=new GTextFormat(FontUtil.songtiName, 12, 16777215);
                loc2.addChild(loc3);
                loc2.addChild(loc4);
                loc2.addChild(loc5);
                loc2.addChild(loc6);
                loc3.width = 162;
                loc4.width = 162;
                loc5.width = 108;
                loc6.width = 108;
                loc4.x = (loc3.width + loc3.x - 1);
                loc5.x = (loc4.width + loc4.x - 1);
                loc6.x = (loc5.width + loc5.x - 1);
                var loc8=ObjCreate.createTextField(Language.getString(41515), 30, -2, 140, 20, loc2, loc7);
                var loc9=ObjCreate.createTextField("80%", loc4.x + 50, -2, 50, 20, loc2, loc7);
                var loc10=ObjCreate.createTextField("100%", loc5.x + 35, -2, 50, 20, loc2, loc7);
                var loc11=ObjCreate.createTextField("60%", loc6.x + 35, -2, 50, 20, loc2, loc7);
                addChild(loc2);
                loc2.toolTipData = toolTipData;
                _bmpMark.bitmapData = GlobalClass.getBitmapData("RoashFishMark");
                addChild(_bmpMark);
                _btnEndRoastFish = ObjCreate.createGLoadedButton(ResFileConst.EndRoashFish, 551, 2, 66, 66);
                addChild(_btnEndRoastFish);
                _btnEndRoastFish.addEventListener(flash.events.MouseEvent.CLICK, onEndRoastFish);
                _btnEndRoastFish.toolTipData = toolTipData;
                return;
            }
            toolTipData = Language.getString(41514);
            this._frameTime = new FrameTimer();
            this._frameTime.addListener(TimerType.ENTERFRAME, this.onRender);
            layer = LayerManager.uiLayer;
            x = (Global.stage.stageWidth - 628) / 2;
            y = Global.stage.stageHeight - 230;
            this._bmpMark = new Object /* flash.display.Bitmap */();
            this._bmpMark.y = 24;
            this._bmpMark.x = -12;
            LoaderHelp.addResCallBack("roashFish", callBack);
            return;
        }

        public onEndRoastFish(arg1: Object /* flash.events.MouseEvent */=null): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.EndRoastFish));
            this._frameTime.stop();
            this.currentInterval = 0;
            this.stopFlicker();
            hide();
            return;
        }

        public startRoash(): void
        {
            show();
            this._bmpMark.x = -12;
            this.currentInterval = 0;
            this.stopFlicker();
            this._frameTime.start();
            return;
        }

        public updateTimers(arg1: int, arg2: int): void
        {
            return;
        }

        /* internal  */onRender(arg1: FrameTimer): void
        {
            this.currentInterval = this.currentInterval + arg1.interval;
            this._bmpMark.x = this.currentInterval / 10000 * 537 - 12;
            if (this.currentInterval >= 3000) 
            {
                this.flicker();
            }
            if (this.currentInterval >= 10000) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.EndRoastFish));
                this.currentInterval = 0;
                arg1.stop();
                this.stopFlicker();
            }
            return;
        }

        /* internal  */flicker(): void
        {
            if (!this.isFlicker) 
            {
                this.isFlicker = true;
                EffectManager.glowFilterReg(this._bmpMark, [FilterConst.chatTipsFilter], 0.6, 10, 1);
                if (this._btnEndRoastFish) 
                {
                    EffectManager.glowFilterReg(this._btnEndRoastFish, [FilterConst.chatTipsFilter], 0.6, 10, 1);
                }
            }
            return;
        }

        /* internal  */stopFlicker(): void
        {
            EffectManager.glowFilterUnReg(this._bmpMark);
            if (this._btnEndRoastFish) 
            {
                EffectManager.glowFilterUnReg(this._btnEndRoastFish);
            }
            this.isFlicker = false;
            return;
        }

        public static get isInitInstance(): Boolean
        {
            return RoashProgressBar._isInitInstance;
        }

        public static get instance(): RoashProgressBar
        {
            if (!RoashProgressBar._instance) 
            {
                RoashProgressBar._instance = new RoashProgressBar();
                RoashProgressBar._isInitInstance = true;
            }
            return RoashProgressBar._instance;
        }

        /* internal */ /* var */_bmpMark: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_btnEndRoastFish: GLoadedButton;

        /* internal */ /* var */_tfRoashTime: Object /* flash.text.TextField */;

        /* internal */ /* var */_frameTime: FrameTimer;

        /* internal */ /* var */currentInterval: int=0;

        /* internal */ /* var */isFlicker: Boolean=false;

        /* internal */ static /* var */_instance: RoashProgressBar;

        /* internal */ static /* var */_isInitInstance: Boolean=false;
    }

            RoashProgressBar._isInitInstance = false;
        